package com.ruoyi.factory.estimate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.factory.estimate.domain.PjrecordView;
import com.ruoyi.factory.estimate.domain.PjrecordViewqz;
import com.ruoyi.factory.estimate.service.IPjrecordViewService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价记录Controller
 * 
 * @author ruoyi
 * @date 2025-09-16
 */
@RestController
@RequestMapping("/api/pjrecordview")
public class PjrecordViewController extends BaseController
{
    @Autowired
    private IPjrecordViewService pjrecordViewService;

    /**
     * 查询评价记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(PjrecordView pjrecordView)
    {
        startPage();
        List<PjrecordView> list = pjrecordViewService.selectPjrecordViewList(pjrecordView);
        return getDataTable(list);
    }

    /**
     * 查询评价记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:listqz')")
    @GetMapping("/listqz")
    public TableDataInfo listqz(PjrecordViewqz pjrecordView)
    {
        startPage();
        List<PjrecordViewqz> list = pjrecordViewService.selectPjrecordViewListqz2(pjrecordView);
        return getDataTable(list);
    }

    /**
     * 导出评价记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:export')")
    @Log(title = "评价记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PjrecordView pjrecordView)
    {
        List<PjrecordView> list = pjrecordViewService.selectPjrecordViewList(pjrecordView);
        ExcelUtil<PjrecordView> util = new ExcelUtil<PjrecordView>(PjrecordView.class);
        util.exportExcel(response, list, "评价记录数据");
    }

    /**
     * 导出评价记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:exportqz')")
    @Log(title = "评价记录", businessType = BusinessType.EXPORT)
    @PostMapping("/exportqz")
    public void exportqz(HttpServletResponse response, PjrecordViewqz pjrecordView)
    {
        List<PjrecordViewqz> list = pjrecordViewService.selectPjrecordViewListqz2(pjrecordView);
        ExcelUtil<PjrecordViewqz> util = new ExcelUtil<PjrecordViewqz>(PjrecordViewqz.class);
        util.exportExcel(response, list, "评价记录数据");
    }

    /**
     * 获取评价记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(pjrecordViewService.selectPjrecordViewById(id));
    }

    /**
     * 新增评价记录
     */
    @PreAuthorize("@ss.hasPermi('system:record:add')")
    @Log(title = "评价记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PjrecordView pjrecordView)
    {
        return toAjax(pjrecordViewService.insertPjrecordView(pjrecordView));
    }

    /**
     * 修改评价记录
     */
    @PreAuthorize("@ss.hasPermi('system:record:edit')")
    @Log(title = "评价记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PjrecordView pjrecordView)
    {
        return toAjax(pjrecordViewService.updatePjrecordView(pjrecordView));
    }

    /**
     * 删除评价记录
     */
    @PreAuthorize("@ss.hasPermi('system:record:remove')")
    @Log(title = "评价记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pjrecordViewService.deletePjrecordViewByIds(ids));
    }
}
